from django.db import models

from common.models import ObjectModel


class Cart(ObjectModel):
    buyer = models.ForeignKey('user.User', on_delete=models.CASCADE)
    product = models.ForeignKey('product.Product', on_delete=models.CASCADE)
    price = models.DecimalField(max_digits=10, decimal_places=2)
    buy_num = models.IntegerField()

    class Meta:
        get_latest_by = 'update_at'
        db_table = 'cart'
